<?php
if(gpcPost("mediabutton", "rename") || gpcPost("mediabutton", "renameexe")) {
  $media_right .= "<fieldset id=\"mediarenamefiles\"><legend>Datei(en) umbenennen</legend>";
  $media_select_files = gpcPost("mediaselectfiles");
  if(!is_array($media_select_files)) {
    $media_right .= "<p>Sie haben kein(e) Datei(en) zum Umbenennen ausgew&auml;hlt</p>";
    $media_right .= "</fieldset>";
    if($media_view == "folder") {
      include_once "fileview.php";
    } else {
      include_once "docuview.php";
    }
  } else {
    if(gpcPost("mediabutton", "renameexe")) {
      $media_right .= "<p>Folgende Datei(en)/Ordner werden umbenannt</p><table>";
      $media_select_files_new = gpcPost("mediaselectfilesnew");
      foreach($media_select_files as $msg=>$msf) {
        if(file_exists($media_checkout2[md5(strtolower($msf))][1])) {
          $media_right .= "<tr><td>".$msf;
          if(is_dir($media_checkout2[md5(strtolower($msf))][1])) {
            $media_right .= "/";
          }
          $media_right .= "</td><td>--></td><td>".$media_select_files_new[$msg]." ";
          if(rename($media_checkout2[md5(strtolower($msf))][1], $media_checkout2[md5(strtolower($msf))][3].$media_select_files_new[$msg])) {
            $media_right .= "<img src=\"css/images/tick.png\" alt=\"tick\" />";
          } else {
            $media_right .= "<img src=\"css/images/cancel.png\" alt=\"cancel\" />";
          }
          $media_right .= "</td></tr>";
        }
      }
      $media_right .= "</table>";
    } else {
      $media_right .= "<form action=\"".$media_linker."&amp;folder=".$showfolder."\" method=\"post\"><table>";
      foreach($media_select_files as $msg => $msf) {
        if(file_exists($media_checkout2[md5(strtolower($msf))][1])) {
          if(is_dir($media_checkout2[md5(strtolower($msf))][1])) {
            $media_right .= "<tr><td>".$msf."/</td>";
          } else {
            $media_right .= "<tr><td>".$msf."</td>";
          }
          $media_right .= "<td>--></td><td><input type=\"text\" name=\"mediaselectfilesnew[".$msg."]\" value=\"".$msf."\" /><input type=\"hidden\" name=\"mediaselectfiles[".$msg."]\" value=\"".$msf."\" /></td></tr>";
        }
      }
      $media_right .= "</table><p><button type=\"submit\" name=\"mediabutton\" value=\"renameexe\" class=\"tooltip\" title=\"Ausf&uuml;hren :: Die Dateien umbenennen\"><img src=\"css/images/tick.png\" alt=\"tick\" /> Ausf&uuml;hren</button> &nbsp; <button type=\"submit\" class=\"tooltip\" title=\"Abbrechen :: Bricht das Umbenennen der Datei(en)/Ordner ab\"><img title=\"next\" alt=\"cancel\" src=\"css/images/cancel.png\"/> Abbrechen</button></p></form>";
    }
    $media_right .= "</fieldset>";
  }
}
?>